using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class KnowsWhenSeen : MonoBehaviour
{
	public bool m_PauseTilSeen = true;
	public bool m_Loop = true;
	public bool m_ResetOnLookAway = true;

	private bool m_imTriggeredNow;
	private bool m_amPaused; 
	private bool m_wasSeen;
	private CanBeSeen cibs;

	public void Start_For_KnowsWhenSeen()
	{
		cibs = GetComponent<CanBeSeen>();
		if ( cibs == null ) cibs = (CanBeSeen) gameObject.AddComponent<CanBeSeen>();
		m_wasSeen = CanIBeSeen();
	}

	public bool CanIBeSeen()
	{
		return cibs.m_IsSeen;
	}

	virtual public void Saw()
	{
		Debug.LogError( "You must override Saw() in your sub class of KnowsWhenSeen" );
	}

	virtual public void LookedAway()
	{
		Debug.LogError( "You must override LookedAway() in your sub class of KnowsWhenSeen" );
	}

	public void Update_For_KnowsWhenSeen() 
	{
		if ( m_wasSeen != cibs.m_IsSeen )
		{
			if ( cibs.m_IsSeen ) 
				 Saw();
			else LookedAway();

			m_wasSeen = cibs.m_IsSeen;
		}
	}
}

